package list;

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        MinStack minStack = new MinStack();
        minStack.push(-2);
        minStack.push(0);
        minStack.push(-1);
        System.out.println(minStack.getMin());
        System.out.println(minStack.top());
        minStack.pop();
        System.out.println(minStack.getMin());
    }

    public static void main5(String[] args) {
        LinkedList list = new LinkedList();
        list.addFirst(1);
        list.addFirst(2);
        list.addFirst(1);
        list.addFirst(3);
        list.display();
        list.clear();
        list.display();
    }
    public static void main4(String[] args) {
        SingleLinkedList list = new SingleLinkedList();
        list.addFirst(1);
        list.addLast(4);
        list.addLast(2);
        list.addLast(9);
        list.addLast(8);
        list.display();
        SingleLinkedList.LinkNode linkNode = list.partition(list.head,3);
        while (linkNode!=null){
            System.out.print(linkNode.val+" ");
            linkNode = linkNode.next;
        }
        System.out.println();

    }
    public static void main3(String[] args) {
        LinkedList list = new LinkedList();
        list.addFirst(1);
        list.addFirst(2);
        list.addFirst(1);
        list.addFirst(3);
        list.addFirst(1);
        //list.display();
        list.addLast(5);
        list.addLast(1);
        list.display();
        list.remove(2);
        list.display();
        list.removeAllKey(1);
        list.display();


    }

    class Solution {
        public static List<List<Integer>> generate(int numRows) {
            List<List<Integer>> Alist = new ArrayList<>();
            List<Integer> list = new ArrayList<>();
            list.add(1);
            Alist.add(list);
            for (int i = 1; i < numRows; i++) {
                List<Integer> a = Alist.get(i - 1);
                List<Integer> b = new ArrayList<>();
                b.add(1);
                for (int j = 1; j < i; j++) {
                    b.add(a.get(j) + a.get(j - 1));
                }
                b.add(1);

                Alist.add(b);

            }
            return Alist;
        }
    }

    public static void main2(String[] args) {
        SingleLinkedList list = new SingleLinkedList();
        list.addFirst(1);
        list.addFirst(1);
        list.addFirst(2);
        list.addFirst(3);
        list.addFirst(4);
        list.addFirst(5);
        list.display();
        list.addLast(100);
        list.display();
        list.addIndex(2,92);
        list.display();
        //list.remove(1);
        //list.display();
        list.removeAllKey(1);
        list.display();
        System.out.println(list.contains(92));
    }

    public static void main1(String[] args) {

        List<List<Integer>> Alist = new ArrayList<>();
        Alist = Solution.generate(4);
        System.out.println(Alist);
    }
}
